<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>

<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <title>${fns:getConfig('productName')}</title>
  <link rel="stylesheet" href="${ctxStatic}/layui-v2.5.6/layui/css/layui.css">
  <script type="text/javascript" src="${ctxStatic}/layui-v2.5.6/layui/layui.js"></script>

</head>
 


<body>



<div class="layui-fluid">
<div class="layui-card">
<div class="layui-form layui-card-header layuiadmin-card-header-auto" style="padding-top: 10px;padding-bottom: 10px;">
   
  <div class="layui-form-item">
  
  
 	<!-- <label class="layui-form-label">部门名称:</label>
		<div class="layui-input-inline" style="width: 160px;">
		     <input type="text" id="updateBy" name="updateBy" autocomplete="off" class="layui-input">
		</div>  -->
	 
	
	<!-- <label class="layui-form-label">起止日期：</label>
		<div class="layui-input-inline" style="width: 160px;">
		     <input type="text" id="fillInDate" name="fillInDate" autocomplete="off" class="layui-input">
		</div>
	<label class="layui-form-label" style="width: 10px;">至</label>
		<div class="layui-input-inline" style="width: 160px;">
		     <input type="text" id="approvalDate" name="approvalDate" autocomplete="off" class="layui-input">审批时间 
		</div> -->
	
	
	<%-- <label class="layui-form-label">年份：</label>
		 <div class="layui-input-inline">
			<select name="year" id="year">
		      	 <option value="">请选择</option>
				<c:forEach items="${fns:getDictList('jx_projectPerformanceReport_year')}" var="year">
					<option value="${year.value}">${year.label}</option>
				</c:forEach>  
			 </select>
		</div>  --%>
		<!-- <div class="layui-input-inline" style="width: 160px;">
		     <input type="text" id="approvalDate" name="year" autocomplete="off" class="layui-input">审批时间 
		</div> -->
     <!-- <button class="layui-btn layuiadmin-btn-comm" id="queryBtn" data-type="reload" lay-submit="" lay-filter="LAY-app-contcomm-search">
         <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>查询
    </button>  -->
   
  </div>
  
</div>
<div class="layui-card-body">
	<table id="table" lay-filter="test" class="demo-tree-more"></table>
</div> 
</div>
</div>
<script type="text/html" id="toolbarDemo">
  <div class="layui-btn-container">
	
    	<button class="layui-btn layui-btn-sm" lay-event="add"><i class="layui-icon layui-icon-add-1"></i>新增</button>
	
  </div>
</script>

<!-- 行工具栏 -->
<script type="text/html" id="barDemo">
      <a class="layui-btn layui-btn-xs layui-btn-normal btn-auth" lay-event="editt" ekper="web/disease/editDisease">添加</a>
	  <a class="layui-btn layui-btn-xs layui-btn-normal btn-auth" lay-event="edit" ekper="web/disease/editDisease">修改</a>
      <a class="layui-btn layui-btn-xs layui-btn-danger btn-auth" lay-event="del" ekper="web/disease/deleteDisease">删除</a>
</script>
<script>
layui.use(['table','form','laydate'], function(){
  var table = layui.table;
  var form = layui.form; 
  var $ = layui.$;
  var laydate = layui.laydate;
  
  var firstDate = new Date();
   firstDate.setDate(1); //第一天
  var endDate = new Date(firstDate);
  endDate.setMonth(firstDate.getMonth()+1);
  endDate.setDate(0);  
   
laydate.render({
			elem: '#createDate',
			trigger: 'click', //采用click弹出
			value: new Date(firstDate)
		});
		//日期
		laydate.render({
			elem: '#updateDate',
			trigger: 'click', //采用click弹出
			value: new Date(endDate)
		});  
  table.render({
	id: 'thisReloadId'
    ,elem: '#table'
    ,height: 650
    ,url:'${ctx}/jx/projectAimTarget/listByAjax'
     ,toolbar: '#toolbarDemo'  //开启头部工具栏，并为其绑定左侧模板
    ,defaultToolbar: ['filter', 'exports', 'print']//layui扩展图功能
     ,title: '绩效管理' 
    ,totalRow:true//开启合计行
    ,cols: [[
             
		{field:'targetOne', title:'一级指标',width:200}
		,{field:'targetTow', title:'二级指标',width:200}	
		,{field:'targetThree', title:'三级指标',width:200}
		,{field:'targetValue', title:'指标值',width:200 /* templet:'<div>{{d.office ? d.office.name : ""}}</div>' */}	/* updateBy更新者 */
		,{field:'performanceStandards', title:'绩效标准',width:200}
		,{field:'createBy', title:'创建者',width:200,  /* templet:'<div>{{d.office ? d.office.name : ""}}</div>'  */}
		,{field:'createDate', title:'创建时间',width:200, /*  templet:'<div>{{d.office ? d.office.name : ""}}</div>' */ }
		,{field:'updateBy', title:'更新者',width:200, /*  templet:'<div>{{d.office ? d.office.name : ""}}</div>'  */}
		,{field:'updateDate', title:'更新时间',width:200, /*  templet:'<div>{{d.office ? d.office.name : ""}}</div>'  */}
		,{field:'remarks', title:'备注',width:200}
      ,{fixed: 'right', title:'操作', toolbar: '#barDemo',width:350}
    ]]
    ,page: false
    ,done: function (res, curr, count) {
    	$(".layui-table th").css({"font-family":"黑体","font-size":"15","font-weight":"bold"});// 设定表格标题字体加粗
    }
  });
  /* $('#queryBtn').on('click', function(){
	  var year = $('#year').val();
     /*  var rent = $('#rent').val();   */
      /*  alert("rent value:"+rent);    
      //执行重载
      table.reload('thisReloadId', {
    	method : 'post',
        where: { //查询条件
        	year: year
        }
      }); 
             alert("你好嘛! value:"+rent);     
  });   */
  
//头工具栏事件
table.on('toolbar(test)', function(obj){
var checkStatus = table.checkStatus(obj.config.id);
data = checkStatus.data; //获取选中的数据
switch(obj.event){
  case 'add':
    layer.open({
    	id:'1',
		type: 2,
	    title: '项目目标指标管理添加',
	    btn: ['关闭'],
	    yes: function(index, layero){
	    	layer.close(index);
	    },
	    shadeClose: true,
	    shade: false,
	    area: ['893px', '650px'],
	    content: '${ctx}/jx/projectAimTarget/form'
	});
  break;
};
});
  
//监听行工具事件
table.on('tool(test)', function(obj){
var data = obj.data;
if(obj.event === 'del'){
  layer.confirm('真的删除该行么？', function(index){
    $.ajax({
        url: "${ctx}/jx/projectAimTarget/deleteById",
        type: "POST",
        dataType: "json",
        data: {
        	id : data.id
        },
        async: false,
        success: function(data){
            layer.close(index);
            //执行重载
            table.reload('thisReloadId', {
              page: {
                curr: 1 //重新从第 1 页开始
              }
            }, 'data');
            layer.msg(data);
        },
        error: function(){
        	layer.msg('删除失败', {icon: 2});
        }
    });
  });
}  else if(obj.event === 'edit'){
	//iframe窗
	layer.open({
		id:'3',
		type: 2,
	    title: '修改指标',
	    btn: ['关闭'],
	    yes: function(index, layero){
	    	layer.close(index);
	    },
	    shadeClose: true,
	    shade: false,
	    area: ['2100px', '920px'],
	    content: '${ctx}/jx/projectAimTarget/form?id='+data.id
	});
} else if(obj.event === 'editt'){
	//iframe窗
	layer.open({
		id:'3',
		type: 2,
	    title: '添加项目指标',
	    btn: ['关闭'],
	    yes: function(index, layero){
	    	layer.close(index);
	    },
	    shadeClose: true,
	    shade: false,
	    area: ['2100px', '920px'],
	    content: '${ctx}/jx/projectAimTarget/form?id='
	});
} 

});
function timestampToTime(timestamp) {
    var date = new Date(timestamp);//时间戳为10位需*1000，时间戳为13位的话不需乘1000
    var Y = date.getFullYear() + '-';
    var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
    var D = date.getDate();
    return Y + M + D;
}
});

</script>
</body>
</html>